import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { GenealogyVO, GenealogyForm, GenealogyQuery } from '@/api/genealogy/genealogy/types';

/**
 * 查询族谱信息列表
 * @param query
 * @returns {*}
 */

export const listGenealogy = (query?: GenealogyQuery): AxiosPromise<GenealogyVO[]> => {
  return request({
    url: '/genealogy/genealogy/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询族谱信息详细
 * @param id
 */
export const getGenealogy = (id: string | number): AxiosPromise<GenealogyVO> => {
  return request({
    url: '/genealogy/genealogy/' + id,
    method: 'get'
  });
};

/**
 * 新增族谱信息
 * @param data
 */
export const addGenealogy = (data: GenealogyForm) => {
  return request({
    url: '/genealogy/genealogy',
    method: 'post',
    data: data
  });
};

/**
 * 修改族谱信息
 * @param data
 */
export const updateGenealogy = (data: GenealogyForm) => {
  return request({
    url: '/genealogy/genealogy',
    method: 'put',
    data: data
  });
};

/**
 * 删除族谱信息
 * @param id
 */
export const delGenealogy = (id: string | number | Array<string | number>) => {
  return request({
    url: '/genealogy/genealogy/' + id,
    method: 'delete'
  });
};
